package io.jt808.proto.cmd;


import io.norland.buffer.AutoBuffer;
import io.norland.annotations.Proto;
import io.norland.proto.IProto;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Proto("8106")
@Data
public class JT8106 implements IProto {

    private byte parametersCount;

    private List<Integer> parametersIDs;

    public byte[] writeToBytes() {
        AutoBuffer buffer = new AutoBuffer();
        buffer.writeByte(parametersCount);
        for (int n : parametersIDs)
            buffer.writeInt(n);
        return buffer.array();

    }

    public void readFromBuf(AutoBuffer buff) {
        parametersCount = buff.readByte();
        parametersIDs = new ArrayList<>();
        while (buff.isReadable())
            parametersIDs.add(buff.readInt());
    }
}